package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;

import com.yuexunit.finance.project.entity.RankingListEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
 *@version 创建时间：2017年1月19日 下午6:29:59
 *@author wenwenlong
 *类说明
 */

@Implements(RankingListService.class)
public class RankingListServiceImpl implements RankingListService {

	@Override
	@Transactional
	public Long createRankingList(RankingListEntity entity) {
		PersistUtil.insert(entity);
		return entity.getRankingId();
	}

	@Override
	@Transactional
	public void updateRankingList(RankingListEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	public List<RankingListEntity> inquireRankingList() {
		DetachedCriteria criteria = DetachedCriteria.forClass(RankingListEntity.class);
		criteria.addOrder(Order.desc("level")).addOrder(Order.asc("time"));
		return PersistUtil.get(criteria);
	}

	@Override
	public RankingListEntity inquireRanking(Long rankingId) {
		return PersistUtil.get(RankingListEntity.class, rankingId);
	}
}
